package cn.edu.bcu.ls.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.io.FileWriter;
import java.io.IOException;

public class AlipayConfig {
    // 应用ID,您的APPID，收款账号既是您的APPID对应支付宝账号
    public static String app_id = "2021001167691750";
    // 商户私钥，您的PKCS8格式RSA2私钥
    public static String merchant_private_key ="MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQC+V40hXRGHl3FOpcE1q7I/0f/Wh6Ax7+1aqwhr6q8jgDubUDUTAN3lvdbn3JyAUMbcbQLde1WTrxXDZlFL1u+BuMiGTn05PgQoa1QIxQS+0yJnoLKvSU39ezFv8ciM2XTXsupcmEng4Dm75lp768HpPQlLdX0qlGNqTPb3kq+eRLKzZZn1gyen6Hstkm/HTbHq/lGkXdlvW7uX2/HrhfZgRzdSIJYnoDsfsvjYYIIZx2gG2CuYkcd0WRvutCXfkFitT00It/JvZc/y78RPGKEILEGmcnigPB94sHV1AQa+aQEsaDyFmvRiQt0EfS8SwprRmEkqaEk+CPS1okKMoOgNAgMBAAECggEBALpuyLYYEXZsmDe/VJo8HPAzwVGgMAEZjrMS+MGy8W5lSHzct89wNuey5M7fn45zEASQ5ZCIIA7yG+/yxMfys06s7gPW1wJ9QtdQINQiHX7HEFjN5paXx0LzKj4KZTPIPpCTFsgxBZO0K/hmLNRZ2+mWtgbqAfn1s9ZHolJlo4vw7FJ79ilsJefgO8t9Akg9vnHlGN7RYpwvTyO3DEjvc6WcTZjKB5RSaXa38sC3mkzPYgYKoPUly2K7pso25ijzOJs09OsnI3ItRVQ9ebXYxdHf+zUfkDd0u62ND2tVu5XF+87n/ydxhn/jn71kc/BItHZmEsj85frh9BDOrFPfW8ECgYEA+LPFGZvWY51fte1eoLJYVYhBbqFhjHeAf1eE9ZVhYzJ+WELFYkuqrVDCMJsE2acmA9ayvl9F6xwJ8xNGnj2uGN4hpU1Vhw6fjGCFudgelHcm3Dliq20ZTXz7/ER02n0GM/z2ZKhExke155gZeVz7wYtTCJUXlchogJ6eazzOdXECgYEAw+1iX0iPiilq45XbBNEGa1KTbnGiYh9uPEBQqyWYyCL1COH/Q3OG4pQvrjsLJGh+c8mubwwZpwWguNseNoj050KFFfVlJRk3l3q+4kV7hyuFUnRH9eoGwmun6j0Z+l3EWBVPvJy2+8GdlB0eB0eZV3AECsqjKsKkJYuWkQ8tHl0CgYEA534dtqqRsgNodWTPMfEPu/2qOhnJPQB3AREr15QGJFl5tRnhtI8N/WkweCGzMA0fm28azYzM/f0JXdLRZrWu+cK5uq3zMFVyOS4XC1eZj0QhTde0ejCA3tm5i6UEx+KcBYQurJ7b9VwGe93dyFO+mvbegRyV6XuzmhULDHJ7EmECgYEAkzx3aqd6xxcs7m6VMt9p9YkOpjbbEuYPz1N9y7/rOquafNxpGeVdfjRiSIqyat/j91uerHDpbiy6hXCVGeJ+OLQykzfglKqIrltdy2jv1bqM7FPaKCGAhuakP1E/jnicrp0FWPZkRHlR1Ba1lD7oK19QilORnva6qERoGAbRnzkCgYEA7L+jfE8bJxvxH/7Hw5SmHMZXq01URcCTa9p0cZSPNJQ4DHUk46//B6yvZhR2bF22cn+yQoDJCIgQ9YD40LrNrykodvcv8IPgEuVXS1jGHRFzA46mu//quv80FspkO4dvU7VlkDUhylIA3I6HaU8f9cPif9f4dBvii5e2tDZBtvg=";
    // 支付宝公钥,查看地址：https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。
    public static String alipay_public_key ="MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm3Ef2CsksEvgyPlVDYje3crBcFZm2PidAW/zBjf9QMK6jUdG93NQsPS4F2Wrzvo9B1d60YYLGmz0cobVqpSq4SVS9ArT5NOzO8e+eU1lJxElhw4ramYlsTHa85/Dp5Ikb8XwP9MTt5l/Ev3PccyHgnPLm5j4RNcyJ8qxoORaRjL2OmfM8mI6MSmmglo4LyoZwRPVG+MJOYTQ+R6P0/HV8cBuTw5QPQ4IMBP+qsWkGBvyRTnv0VnQ6vYnSt+trhzKVWTxaKlqJRthlS0Mgj6Lxkr9EeA+v8MA9ZJph7jB0xqg/kRoPkU3uByJYhdlQq8m5gC2prOnr4QFyb+2OuyciwIDAQAB";
    // 服务器异步通知页面路径  需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网可以正常访问，测试修改springboot端口和外网地址
    public static String notify_url = "http://www.lszjx.com:8081/learn/notify_url";
    // 页面跳转同步通知页面路径 需http://格式的完整路径，不能加?id=123这类自定义参数，必须外网（通过netapp获取net123或自己购买生成）可以正常访问
    public static String return_url = "http://www.lszjx.com:8081/learn/return_url";
    // 签名方式
    public static String sign_type = "RSA2";
    // 字符编码格式
    public static String charset = "utf-8";
    // 支付宝网关
    public static String gatewayUrl = "https://openapi.alipaydev.com/gateway.do";
    // 支付宝网关
    public static String log_path = "D:\\";
    /** * 写日志，方便测试（看网站需求，也可以改成把记录存入数据库）*/
    public static void logResult(String sWord) {
        FileWriter writer = null;
        try {
            writer = new FileWriter(log_path + "alipay_log_" + System.currentTimeMillis()+".txt");
            writer.write(sWord);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}


